package com.sicau.smart_farmer.controller;


import com.sicau.smart_farmer.common.ResultVO;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @author sxt
 * @create 2019-11-08 21:34
 */

@ControllerAdvice
public class ExceptionController {

    @ExceptionHandler
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    @ResponseBody
    public ResultVO handleDefaultException(Exception e){
        e.printStackTrace();
        return ResultVO.FAILED(e.getMessage());
    }

//    @ExceptionHandler(TemplateInputException.class)
//    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
//    @ResponseBody
//    public ResultVO handleTemplateInputException(Exception e){
//        e.printStackTrace();
//        System.out.println("11111");
//        return ResultVO.FAILED(e.getMessage());
//    }

}
